package com.client.goods;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;

import net.sf.json.JSONObject;

import com.client.base.BaseAction;
import com.client.base.BaseForm;
import com.client.base.ClientUtils;
import com.client.base.GetJSonData;
import com.client.login.mobile.action.OrderlistForm;

@Controller("/listGoodsSaleDeptDtlAction")
public class ListGoodsSaleDeptDtlAction extends BaseAction{
	
	@Override
	public String process(BaseForm reqForm, HttpServletRequest request,
			HttpServletResponse response) throws IOException, ServletException {
		String operation=reqForm.getOperation();
		if("neworderlist".equals(operation)){
			return getGoodsSaleDeptJsonData(reqForm, request,response);
		}else{
			return "listGoodsSale";
		}
	}

	private String getGoodsSaleDeptJsonData(BaseForm reqForm,
			HttpServletRequest request, HttpServletResponse response) {
		PrintWriter out = null;
		Map map=new HashMap();
		JSONObject js = new JSONObject();
		try {
			response.setContentType("text/json;charset=UTF-8");
			out= response.getWriter();
			js=JSONObject.fromObject(ClientUtils.getResponseBody(ClientUtils.listGoodsSaleDept, new String[]{ClientUtils.requestDataName,GetJSonData.getGoodSaleJsonData(map).toString()}));
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			out.print(js.getString("dataList"));
			out.flush();
			out.close();
		}
		return null;
	}
}
